package com.gnerv.sylvanas.business.manage.operation;

import com.gnerv.sylvanas.framework.core.BaseCurrentAccount;
import com.gnerv.sylvanas.business.manage.model.bo.DictItemBO;
import com.gnerv.sylvanas.business.manage.model.entity.DictItem;
import com.gnerv.sylvanas.business.manage.model.vo.DictItemVO;
import com.gnerv.sylvanas.business.manage.storage.DictItemStorageService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Gnerv LiGen
 */
@Service
@AllArgsConstructor
public class DictItemOperationService {

    private final DictItemStorageService dictItemStorageService;
    private final BaseCurrentAccount baseCurrentAccount;

    
    @Transactional(rollbackFor = {Exception.class})
    public boolean create(DictItemBO dictItemBO) {
        DictItem dictItem = dictItemBO.toDictItem();
        
        dictItemStorageService.insert(dictItem);
        return true;
    }

    
    @Transactional(rollbackFor = {Exception.class})
    public boolean deleteByUkId(String ukId) {
        dictItemStorageService.deleteByUkId(ukId);
        return true;
    }

    
    @Transactional(rollbackFor = {Exception.class})
    public boolean deleteByDictUkId(String dictUkId) {
        dictItemStorageService.deleteByDictUkId(dictUkId);
        return true;
    }

    
    @Transactional(rollbackFor = {Exception.class})
    public boolean updateByUkId(DictItemBO dictItemBO) {
        DictItem dictItem = dictItemBO.toDictItem();
        dictItemStorageService.updateByUkId(dictItem);
        return true;
    }

    
    @Transactional(readOnly = true)
    public DictItemVO selectVOByUkId(String ukId) {
        return dictItemStorageService.selectVOByUkId(ukId);
    }

    
    @Transactional(readOnly = true)
    public List<DictItemVO> selectListVOByDictUkId(String dictUkId) {
        return dictItemStorageService.selectListVOByDictUkId(dictUkId);
    }

}




